// 初始化监控覆盖率模型对象
function initMonitoringCoverageModel() {
    let data = {
      basicConfigTableCount: 0, // 基础规则数量
      businessConfigTableCount: 0, // 业务规则数量
      tableCount: 0, // 总表数
      businessPencent: '0.00', // 业务百分比
      basicPencent: '0.00', // 基础百分比
      statTime: "", // 查询时间
      levelEname: "" // 类型
    }
  
    let ODS = Object.assign({}, data);
    ODS.levelEname = "ODS"
    let CDM = Object.assign({}, data);
    CDM.levelEname = "CDM"
    let ADS = Object.assign({}, data);
    ADS.levelEname = "ADS"
    return {
      ODS,
      CDM,
      ADS
    }
  }
  
  // 监控覆盖率请求后赋值表的调用
  function show384_cellInit() {
    console.log('init show384');
    let {
      ODS,
      CDM,
      ADS
    } = initMonitoringCoverageModel();
    let show384_table_data = se.getCellOptions('show384').data; // 表数据
    //   console.log("show384_table_data", show384_table_data);
    let dataObj = {
      ODS,
      CDM,
      ADS
    };
    if (show384_table_data && show384_table_data.length > 1) {
      for (let i = 1; i < show384_table_data.length; i++) {
        let tempObj = {}
        for (let j = 0; j < show384_table_data[0].length; j++) {
          tempObj[show384_table_data[0][j]] = show384_table_data[i][j]
        }
        if (dataObj[tempObj.levelEname]) {
          dataObj[tempObj.levelEname] = tempObj;
        }
      }
    }
  
    let divObj = getMonitoringCoverageDivObj();// 获取对应要复制对象的组件
    setTimeout(function() {
      for (let name in divObj) {
        if (name) {
          for (let key in divObj[name]) {
            let divItems = divObj[name][key];
            for (let i = 0; i < divItems.length; i++) {
              let id = divItems[i]; // 组件的id
              setGirdData(id, dataObj[name][key]);
            }
          }
        }
      }
  
    }, 100)
  
  }
  // 设置组件单元格内容
  function setGirdData(id, text) {
  
    let cell = se.graph.model.cells[id];
    let cell_index = se.getCellIndex(cell);
    let cell_dom = se.parentSelector.querySelectorAll("." + cell.type);
    let cell_tempDom = cell_dom[cell_index]
    //   console.log("cell_index", cell_index)
    //   console.log("cell_dom", cell_dom)
    //   console.log("cell_tempDom", cell_tempDom)
    cell_tempDom.children[0].children[1].innerText = text
  }
  // 获取监控覆盖对应组件id
  function getMonitoringCoverageDivObj() {
    let ODS = {
      basicConfigTableCount: ["show369"],
      basicPencent: ['show358'],
      businessConfigTableCount: ["show371"],
      businessPencent: ["show357"],
      tableCount: ["show372", "show373"]
    }
    let CDM = {
      basicConfigTableCount: ["show356"],
      basicPencent: ['show359'],
      businessConfigTableCount: ["show375"],
      businessPencent: ["show366"],
      tableCount: ["show376", "show377"]
    }
    let ADS = {
      basicConfigTableCount: ["show367"],
      basicPencent: ['show364'],
      businessConfigTableCount: ["show378"],
      businessPencent: ["show360"],
      tableCount: ["show379", "show380"]
    }
  
    return {
      ODS,
      CDM,
      ADS
    }
  }
  // 获取监控覆盖率模型对象  —— 暂时使用监控覆盖率字段，之后替换成表对应字段
  function getExecutionAnomalyRateDivObj() {
    let ODS = {
        basicConfigTableCount: ["show395"],// 执行异常率——基础规则_贴源数据层ODS异常规则数：
        basicPencent: [],
        businessConfigTableCount: ["show396"],//执行异常率——基础规则_公共数据层CDM异常规则数：
        businessPencent: ["show393"], // 执行异常率——基础规则率
        tableCount: ["show398", "show397"]//  总数——show398  执行异常率基础ADS异常数show397
      }
      let CDM = {
        basicConfigTableCount: ["show399"],//   执行异常率——业务规则率_贴源数据层ODS异常规则数：
        basicPencent: [],
        businessConfigTableCount: ["show400"],//    行异常率——业务规则率_公共数据层CDM异常规则数：
        businessPencent: ["show394"],// 执行异常率——业务规则率
        tableCount: ["show402", "show401"]//  总数——show402  执行异常率基础ADS异常数   show401
      }
  
    return {
      ODS,
      CDM,
    }
  }

  // 初始化监控覆盖率模型对象
function initExecutionAnomalyRateModel() {
    let data = {
      basicConfigTableCount: 0, // 基础规则数量
      businessConfigTableCount: 0, // 业务规则数量
      tableCount: 0, // 总表数
      businessPencent: '0.00', // 业务百分比
      basicPencent: '0.00', // 基础百分比
      statTime: "", // 查询时间
      levelEname: "" // 类型
    }
  
    let ODS = Object.assign({}, data);
    ODS.levelEname = "ODS"
    let CDM = Object.assign({}, data);
    CDM.levelEname = "CDM"
    return {
      ODS,
      CDM
    }
  }
  
  // 执行异常率请求后赋值表的调用
  /**
   * 执行逻辑
   * 1、获取数据模型对象默认值
   * 2、获取表格数据
   * 3、遍历表格数据，将表格数据赋值给数据模型对象
   * 4、获取对应要复制对象的组件
   * 5、遍历数据模型对象，将数据模型对象赋值给对应组件
   * 6、将组件的数据模型对象赋值给组件
   */
  function show392_cellInit() {
    console.log('init show392');
    let {ODS,CDM} = initExecutionAnomalyRateModel();//1、获取数据模型对象默认值
    let show392_table_data = se.getCellOptions('show392').data; // 表数据 获取表格数据
    //   console.log("show392_table_data", show392_table_data);
    let dataObj = {ODS,CDM};
    if (show392_table_data && show392_table_data.length > 1) {
        for (let i = 1; i < show392_table_data.length; i++) {
            let tempObj = {}
            for (let j = 0; j < show392_table_data[0].length; j++) {
                tempObj[show392_table_data[0][j]] = show392_table_data[i][j]
            }
            if (dataObj[tempObj.levelEname]) {
                dataObj[tempObj.levelEname] = tempObj;
            }
        }
    }

    let divObj = getExecutionAnomalyRateDivObj();
    setTimeout(function() {
        for (let name in divObj) {
            if (name) {
                for (let key in divObj[name]) {
                    let divItems = divObj[name][key];
                    for (let i = 0; i < divItems.length; i++) {
                        let id = divItems[i]; // 组件的id
                        setGirdData(id, dataObj[name][key]);
                    }
                }
            }
        }

    }, 100)
  }